/*
 * Copyright 2010 Christoph Widulle (christoph.widulle@googlemail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
 * License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */


package com.android1.amarena2d.engine;


import com.badlogic.gdx.Files;

import java.util.HashMap;

public class Config {

    public static final String TIMER_LIFECYCLE_POOL_SIZE = "timer.lifecycle.pool.size";
    public static final String TIMER_CALLBACK_POOL_SIZE = "timer.callback.pool.size";
    public static final String TIMER_MAX_ACTIVE = "timer.maxActive";
    public static final String TIMER_MAX_BY_LIFECYCLE_OBJECT = "timer.lifecycleobject.max";
    public static final String TOUCHSPOTS_MAX = "touchspots.max";
    public static final String LISTENER_MAX = "listener.max";
    public static final String ACTIONS_MAX_CONCURRENT_BY_TARGET = "actions.targets.maxConcurrentActions";
    public static final String ACTIONS_MAX_TARGETS = "actions.targets.max";
    public static final String EMITTER_MAX_PER_SYSTEM = "emitter.maxBySystem";
    public static final String COLLISION_MAX_OBJECTS = "collision.maxObjects";
    public static final String LIBRARY_MAX_ENTITY = "system.entity.max";
    public static final String NODE_MAX_CHILDREN = "node.maxChildren";

    private final HashMap<String, Integer> props;
    private int cameraWith;
    private int cameraHeight;
    private boolean useGL20IfAvailable;
    private String baseAssetsPath = "";
    private Files.FileType defaultFileType = Files.FileType.Internal;


    public Config() {

        props = new HashMap<String, Integer>();

        props.put(TIMER_LIFECYCLE_POOL_SIZE, 50);
        props.put(TIMER_CALLBACK_POOL_SIZE, 50);
        props.put(TIMER_MAX_ACTIVE, 50);
        props.put(TIMER_MAX_BY_LIFECYCLE_OBJECT, 4);
        props.put(TOUCHSPOTS_MAX, 40);
        props.put(LISTENER_MAX, 10);
        props.put(ACTIONS_MAX_CONCURRENT_BY_TARGET, 6);
        props.put(ACTIONS_MAX_TARGETS, 40);
        props.put(EMITTER_MAX_PER_SYSTEM, 35);
        props.put(COLLISION_MAX_OBJECTS, 70);
        props.put(LIBRARY_MAX_ENTITY, 50);
        props.put(NODE_MAX_CHILDREN, 50);

    }

    public Config(int cameraWith, int cameraHeight) {
        this(cameraWith, cameraHeight, false);
    }

    public Config(int cameraWith, int cameraHeight, boolean useGL20IfAvailable) {
        this();
        this.useGL20IfAvailable = useGL20IfAvailable;
        this.cameraWith = cameraWith;
        this.cameraHeight = cameraHeight;
    }

    public String getBaseAssetsPath() {
        return baseAssetsPath;
    }

    public void setBaseAssetsPath(String baseAssetsPath) {
        this.baseAssetsPath = baseAssetsPath;
    }

    public Files.FileType getDefaultFileType() {
        return defaultFileType;
    }

    public void setDefaultFileType(Files.FileType fileType) {
        this.defaultFileType = fileType;
    }

    public Config set(String key, int value) {
        props.put(key, value);
        return this;
    }

    public boolean useGL20IfAvailable() {
        return useGL20IfAvailable;
    }

    public Config setUseGL20IfAvailable(boolean useGL20IfAvailable) {
        this.useGL20IfAvailable = useGL20IfAvailable;
        return this;
    }

    public int get(String key) {
        return props.get(key);
    }


    public int getCameraWith() {
        return cameraWith;
    }

    public int getCameraHeight() {
        return cameraHeight;
    }

}
